var menuFile = function () {
    this.html = $("<div id='menu'></div>");
    this.buttons = {};
    this.definetButton = null;
};
menuFile.prototype = {
    constructor: this,
    render: function () {
        return this.html;
    },
    addButton: function (options) {
        for (let i = 0; i < options.length; i++) {
            const buttonItem = options[i];
            this.buttons[buttonItem.key] = new menuItem(buttonItem, this);
            this.html.append(this.buttons[buttonItem.key].render());
        };
    },
    unActive: function () {
        for (const key in this.buttons) {
            if (this.buttons.hasOwnProperty(key)) {
                const item = this.buttons[key];
                item.unActive();
            };
        };
    }
};
var menuItem = function (buttonData, parent) {
    this.buttonData = buttonData;
    this.parent = parent;
    this.event = {
        show: buttonData.showEvent,
        hide: buttonData.hideEvent
    };
};
menuItem.prototype = {
    constructor: this,
    render: function () {
        this.element = $("<div class='item' title='" + this.buttonData.title + "'><i class='fa " + this.buttonData.icon + "'></i></div>");
        if (this.buttonData.active) {
            this.active();
        } else {
            this.unActive();
        };
        this.element.click((e) => {
            this.active();
        });
        return this.element;
    },
    active: function () {
        this.parent.unActive();
        this.element.addClass("active");
        this.event.show();
    },
    unActive: function () {
        this.element.removeClass("active");
        this.event.hide();
    },
    onShow: function (event) {
        this.event.show = event;
    },
    onHide: function (event) {
        this.event.hide = event;
    }
};
module.exports = function () {
    return new menuFile();
};